package cn.js.sangu.unitStore.entity;

import cn.hutool.core.annotation.Alias;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@TableName("process_node")
@JsonIgnoreProperties(ignoreUnknown = true) // 忽略JSON中未定义的字段，增强程序健壮性
public class ProcessNode {

    @TableId(type = IdType.AUTO)
    private Integer id;

    @Alias("流程模板ID")
    private Integer templateId;

    @Alias("节点步骤")
    private Integer step;

    @Alias("节点名称")
    private String stepName;

    @Alias("步骤类型")
    private Integer stepType;

    @Alias("备注描述")
    private String description;

    @Alias("节点负责人ID")
    private Integer handler;

    @Alias("节点负责人名称")
    // @TableField(exist = false)
    private String handlerName;

    @Alias("修改人ID")
    private Integer modifier;

    @Alias("创建时间")
    @TableField(fill = FieldFill.INSERT)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
    private Date creatTime;

    @Alias("更新时间")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
    private Date updateTime;

    @Alias("备注")
    private String remark;

    @Alias("创建人id")
    private Integer userId;

    @Alias("创建人名称")
    @TableField(exist = false)
    private String username;

    @Alias("状态")
    private Integer state;

    @Alias("走步骤时间")
    @TableField(exist = false)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
    private Date stepTime;

}
